<!--
 * @Description: 资源分类选择页面
 * @Author: JiangMing
 * @Date: 2021-09-8 16:23:00
 * @LastEditors: JiangMing
 * @LastEditTime: 2021-09-8 16:23:00
-->
<template>
  <view class="page">
    <SearchBar ref="searchBar" class="page-header" />
    <view class="content">
      <uni-list>
        <uni-list-item
          v-for="(item,index) in list"
          :key="index"
          :title="item.name"
          showArrow
          clickable
          @click="linkTo(item)"
        >
          <template slot="header">
            <image :src="item.icon" mode="aspectFit" class="icon"></image>
          </template>
        </uni-list-item>
      </uni-list>
    </view>
  </view>
</template>

<script>
import SearchBar from '@/components/searchBar';

export default {
  components: {
    SearchBar
  },
  data() {
    return {
      list: [
        { name: '物资', type: 'a1', icon: require('@/static/images/wuzi.png') },
        { name: '队伍', type: 'a2', icon: require('@/static/images/duiwu.png') },
        { name: '专家', type: 'a3', icon: require('@/static/images/zhuanjia.png') },
        { name: '机构', type: 'a4', icon: require('@/static/images/jigou.png') },
        { name: '场所', type: 'a5', icon: require('@/static/images/changshuo.png') },
        { name: '运输力', type: 'a6', icon: require('@/static/images/yunshu.png') },
      ]
    }
  },
  onLoad() {
    // #ifdef APP-NVUE
    this.eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
    // #endif
    // #ifndef APP-NVUE
    this.eventChannel = this.getOpenerEventChannel();
    // #endif
  },
  methods: {
    linkTo(row) {
      // this.$emit('classClick', row);
      uni.navigateTo({
        url: `/pages/resource/index?type=${row.type}&title=${row.name}`,
        events: {
          resourceChange: (data) => {
            this.eventChannel.emit('resourceChange', data);
          }
        }
      })
    },
  }
}
</script>

<style lang="scss" scoped>
.page {
  display: flex;
  flex-direction: column;
  height: 100%;
  .content {
    flex: 1;
    overflow-y: auto;
    ::v-deep .uni-list-item__container {
      padding-top: 36rpx;
      padding-bottom: 36rpx;
      align-items: center;
    }
    .icon {
      height: 32rpx;
      max-width: 40rpx;
      margin-right: 20rpx;
    }
  }
}
</style>